//
//  ZZCHeadCollectionReusableView.m
//  B段项目
//
//  Created by dllo on 15/12/24.
//  Copyright © 2015年 张智超. All rights reserved.
//

#import "ZZCHeadCollectionReusableView.h"

@interface ZZCHeadCollectionReusableView ()<SDCycleScrollViewDelegate>

@property (nonatomic, retain)SDCycleScrollView *headScroll;
@property (nonatomic, retain)NSMutableArray *urlArray;

@end

@implementation ZZCHeadCollectionReusableView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self createSubViews];
    }
    return self;
}

- (void)createSubViews
{
    self.headScroll = [[SDCycleScrollView alloc] initWithFrame:self.bounds];
    [self addSubview:self.headScroll];
    self.headScroll.delegate = self;
    
    self.urlArray = [[NSMutableArray alloc] init];
    

}


-(void)setArray:(NSMutableArray *)array
{
    _array = array;
    
    NSMutableArray *myArray = [NSMutableArray array];
    
    for (NSMutableDictionary *dic in self.array) {
        [self.urlArray addObject:[dic objectForKey:@"url"]];
        [myArray addObject:[dic objectForKey:@"img"]];
    }
    
    self.headScroll.imageURLStringsGroup = myArray;
    self.headScroll.pageControlAliment = SDCycleScrollViewPageContolAlimentRight;

    
}

- (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index
{
    NSString *tempStr = self.urlArray[index];
    self.strId = [tempStr substringWithRange:NSMakeRange(17, 24)];
    [self.readHeadDelegate presentToViewControllerContentId:self.strId];
}




@end
